<%@ page import="pojo.Manager" %>
<%@ page import="java.util.List" %>
<%@ page import="pojo.Goods" %><%--
  Created by IntelliJ IDEA.
  User: konley
  Date: 2020/6/19
  Time: 23:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>小米商城 | 后台管理</title>
    <script src="${pageContext.request.contextPath }/js/jquery-3.4.1.js" type="text/javascript"
            charset="utf-8"></script>
    <script src="${pageContext.request.contextPath }/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/mistore.css"/>
    <script src="${pageContext.request.contextPath }/js/mistore.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath }/js/managerView.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<!--top-->
<div id="navi">
    <div style="background-color:#333333;" id="nav">
        <div class="container" style="height: 40px">
            <div class="row">
                <div class="col-sm-8" style="margin-top: 9px">
                    <ul class="top-nav" style="float: left">
                        <li><a href="index.jsp">小米商城</a></li>
                        <li>|</li>
                        <li><a href="#">MIUI</a></li>
                        <li>|</li>
                        <li><a href="#">IoT</a></li>
                        <li>|</li>
                        <li><a href="#">云服务</a></li>
                        <li>|</li>
                        <li><a href="#">小爱开放平台</a></li>
                        <li>|</li>
                        <li><a href="#">企业团购</a></li>
                        <li>|</li>
                        <li><a href="#">资质证照</a></li>
                        <li>|</li>
                        <li><a href="#">规则协议</a></li>
                        <li>|</li>
                        <li><a href="#">下载app</a></li>
                        <li>|</li>
                        <li><a href="#">Select Location</a></li>
                    </ul>
                </div>
                <% Manager manager = (Manager) session.getAttribute("manager");%>
                <div class="col-sm-4" style="margin-top: 9px">
                    <ul class="top-nav" style="float: left">
                        <li style="color: #ec971f">欢迎您，管理员，工号<%=manager.getId()%>
                        </li>
                        <li>|</li>
                        <li><a href="index.jsp">返回主页</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<br><br>
<div class="container">
    <div style="height: 400px">
        <!--搜索框-->
        <div class="row">
            <div class="col-sm-6 sm col-sm-offset-3 text-center">
                <h2>小米商城在库商品搜索</h2>
                <kbd>请输入关键字，默认查询所有</kbd><br>
            </div>
        </div>
        <br>
        <br>
        <!--搜索框组-->
        <div class="row">
            <div class="col-sm-4 col-sm-offset-4 text-center">
                <form role="form" action="FindGoodsServlet">
                    <div class="input-group">
                        <input type="text" name="comm" id="comm" placeholder="请输入商品名" class="form-control">
                        <span class="input-group-btn">
						<button class="btn btn-default" type="submit" id="btn-search">搜索</button>
                        </span>
                        <span class="input-group-btn">
						<a href="addGoods.jsp"><button class="btn btn-success" type="button">添加</button></a>
                        </span>
                    </div>
                    <div class="input-group">
                        <div id="div01"></div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!--搜索结果-->
    <% List<Goods> list = null;
        if (request.getAttribute("list") != null) {
            list = (List<Goods>) request.getAttribute("list");
        }
        if (list != null) {
    %>
    <!--显示学生信息-->
    <div class="row">
        <div class="col-sm-8 col-sm-offset-2 text-center">
            <table class="table table-striped table-bordered table-hover text-center">
                <thead>
                <tr>
                    <td>商品编号</td>
                    <td>商品名</td>
                    <td>类型</td>
                    <td>价格</td>
                    <td>操作</td>
                </tr>
                </thead>
                <tbody>
                <% for (Goods goods : list) { %>
                <tr>
                    <td><%=goods.getId()%>
                    </td>
                    <td><%=goods.getName()%>
                    </td>
                    <td><%=goods.getType()%>
                    </td>
                    <td><%=goods.getMoney()%>
                    </td>
                    <td>
                        <a href="ShowGoods?id=<%=goods.getId()%>">查看</a>  |
                        <a href="GoodsServlet?m=update&id=<%=goods.getId()%>">修改</a> |
                        <script type="text/javascript">
                            function confirmdel() {
                                if (confirm("确认删除该商品的所有信息，该操作不可逆 ！"))
                                    return true;
                                return false;
                            }
                        </script>
                        <a href="GoodsServlet?m=delete&id=<%=goods.getId()%>" onclick="return confirmdel()">删除</a>
                    </td>
                </tr>
                <% } %>
                </tbody>
            </table>
        </div>
    </div>
    <%}%>
    <!--底栏-->
    <div class="container">
        <div class="row" style="margin-top: 20px">
            <div class="col-sm-12 text-center" style="margin-top: 50px">
                <p>简体 | 繁体 | Englis | 常见问题 | 隐私政策</p>
                <p>小米公司版权所有 -京ICP备10046444 -京公网安备11010802020134号 -京ICP证110507号</p>
            </div>
        </div>
    </div>
</div>
</body>
</html>
